package file;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

public class LearnIO {

	public static void main(String[] args) throws IOException {
		t3();
	}
	public static void t1(){
		System.out.println(File.separator);//\
		System.out.println(File.pathSeparator);//;
	}
	public static void t2(){
		String fileName="D:"+File.separator+"good.txt";
		File file=new File(fileName);
		try {
			file.createNewFile();//创建一个文件
			file.delete();//删除一个文件
			//file.mkdir();//创建一个文件夹
			/*String[] files=file.list();//列出目录全部文件,包含隐藏文件(listFiles()列出文件加路径)
			System.out.println(files);*/
			//System.out.println(file.isDirectory());//判断是否为路径
		} catch (IOException e) {
			System.out.println(e.getLocalizedMessage());
			e.printStackTrace();
		}
	}
	public static void t3() throws IOException{
        String fileName="D:"+File.separator+"hello.txt";
        File f=new File(fileName);
        RandomAccessFile demo=new RandomAccessFile(f,"rw");
        demo.writeBytes("asdsad");
        demo.writeInt(12);
        demo.writeBoolean(true);
        demo.writeChar('A');
        demo.writeFloat(1.21f);
        demo.writeDouble(12.123);
        demo.close();  
	}

}
